This overivew provides a description of an R package called FARS which represents routines for extraction and basic summarization of National Highway Traffic Safety (NHTS) Administration's Fatality Analysis Reporting System data set (which can be found at https://www.nhtsa.gov/research-data/fatality-analysis-reporting-system-fars).
This project was done in partial fullfillment of the Coursera Course "Building R Packages" as developed by John Hopkins University. The author took this course in March of 2018.
library(FARS) library(dplyr) library(maps)
The FARS package is composed of the following elements or data handling routines:
The following packages are loaded and required by the package.
library(FARS) library(maps)
Data files can be found at
list.files(system.file("extdata", package = "FARS"))
This function reads in data set from the NHTSA Fatality Analysis Reporting System (FARS).
df<-fars_read("accident_2014.csv.bz2")
This function creates a data file name based on the selected year.
df<-make_filename(2014)
Read the desired yearly data file and create a new data set with two variables, month and year.
df<-fars_read_years(2013:2015)
This function creates a simple tabular summary of accident counts by year and month.
fars_summarize_years(2013:2015)
This function provides a geographic summary of accident locations with a simple state map.
fars_map_state(13,2014)
Note: For a listing of state numbers, refer to https://crashstats.nhtsa.dot.gov/Api/Public/ViewPublication/812449
The current package FARS is based on extraction of data elements covering the years 2013-205 e.g. those files that are found within the working directory. The package could be applied to additional data sets as long as they are of a similar format and can be found in the working directory.
National Highway Traffic Safety Administration's Fatality Analysis Reporting System data set. https://www.nhtsa.gov/research-data/fatality-analysis-reporting-system-fars
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.